package com.ewing.busi.carry.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;

import com.ewing.busi.carry.dto.ChangeAddressRep;
import com.ewing.busi.carry.dto.WebCarryWayResp;
import com.ewing.busi.carry.service.WebCarryService;
import com.ewing.common.exception.BusinessException;
import com.ewing.core.app.action.base.BaseAction;

/**
 * 
 * @author chenxuegui@163.com
 * @createDate 2016年9月4日
 */
public class WebCarryAction extends BaseAction {

  private static Logger logger = Logger.getLogger(WebCarryAction.class);

  @Resource
  private WebCarryService webCarryService;

  /**
   * 
   */
  private static final long serialVersionUID = 1L;


  /**
   * 根据web_resource id 及城市查找对应的运费方式
   * 
   * @author Joeson
   */
  public void changeAddress() {
    try {
      ChangeAddressRep req = getParamJson(ChangeAddressRep.class);
      checkRequired(req.getOrderId(), "orderId");
      checkRequired(req.getCity(), "city");

      List<WebCarryWayResp> list =
          webCarryService.findByOrderIdAndRegion(getLoginCusId(), req.getOrderId(), req.getCity());
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("list", list);
      outSucResult(map);
    } catch (BusinessException e) {
      logger.error(e.getMessage(), e);
      outFailResult("内部异常");
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      outFailResult("内部异常");
    }
  }

}
